package com.tony.controller;

import com.google.common.base.Preconditions;
import com.tony.thread.ThreadPoolManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author tony
 * @Date 2018/11/23
 */
@RestController
@Api("消息获取处理API")
public class MessageController {

    @Autowired
    private ThreadPoolManager threadPoolManager;

    @ApiOperation(value = "传入消息", notes = "拼接上时间和随机数字后进行处理")
    @ApiImplicitParam(name = "msg", value = "消息", paramType = "path", required = true, dataType = "String")
    @RequestMapping("/notice/{msg}")
    public void getMsg(@PathVariable String msg){
        String randomStr = msg+"####"+System.currentTimeMillis() + UUID.randomUUID().toString();
        threadPoolManager.addMsg(randomStr);
    }

    @RequestMapping("/tell")
    public void say(){
        String randomStr = "####"+System.currentTimeMillis() + UUID.randomUUID().toString();
        threadPoolManager.addMsg(randomStr);
    }

}
